1. Field of the Invention
This invention relates to an optical code reader that utilizes a binarization circuit for binarizing an inputted electric signal, and the binarization circuit.
2. Description of the Related Art
A bar code reader is known as a typical optical code reader. The bar code reader scans a bar code comprising a plurality of white and black bars with laser beams. When the beams reflected from the bar code are converted to electric signals, binarized signals of high and low levels can be acquired. The bar code reader decodes the content of the bar code on the basis of these signals. Besides the bar code reader, optical code readers containing such a binarization circuit include an image scanner, an OCR, a FAX, and so forth.
In the bar code readers according to the prior art, resolution drops if the beam diameter of the laser beam is greater than the width of each bar of the bar code. In this case, it is difficult to obtain the binarized electric signals that are clearly distinguished into the high and low levels. Therefore, it has been the customary technology to differentiate the electric signals acquired from the reflected beams from the bar code, to compare the signals so differentiated with a reference level (or a slice level), and to thus binarize the electric signals.
FIG. 1 shows a circuit construction for executing a binarization process in a bar code reader according to the prior art.
When a scanning mechanism 11 scans a bar code 13 with laser beams 12, a reflected beam attains a high level when the beams 12 scan white bars and falls to a low level when they scan black bars. A pin photodiode 16 receives the reflected beams and outputs electric signals in accordance with these levels.
FIG. 2 shows the relationship between the bar code and the electric signal as the output of the pin photodiode. When the beams 12 scan the bar code 13 printed on a sheet 17 from the left to the right in the drawing, the output waveform of the pin photodiode 16 rises to the high level when the beams 12 scan the white bars 14, and falls to the low level when the beams scan the black bars 15.
Turning back to FIG. 1, the electric signal is amplified by an amplification unit 21 and is differentiated by a differentiation unit 22. The differentiation signal DF so obtained exhibits a large positive value when the edge of the white bar 14 is detected, and a large negative value when the edge of the black bar 15 is detected.
A peak-hold circuit 27 inside the slice level generation unit 25 holds the peak value VDF of the differentiation signal DF. A voltage division circuit 29 executes voltage division of the level of this peak value VDF at a predetermined ratio, and generates the slice level SL. The slice level SL is inputted to a first comparison circuit 23 and is then compared with the differentiation signal DF. A slice level xe2x88x92SL, that is generated by inverting the polarity of the slice level SL by an inverter 37, is inputted to a second comparison circuit 24 and is compared with the differentiation signal DF.
When the level of the differentiation signal DF becomes higher than the slice level SL, the first comparison circuit 23 outputs a gate signal W-GATE. When the level of the differentiation signal DF becomes higher than the slice level xe2x88x92SL, the second comparison circuit 24 outputs the gate signal B-GATE. These gate signals W-GATE and B-GATE are utilized as the gate signals of a circuit that detects the edge of the white bar 14 or the edge of the black bar 15.
The bar code 13 is not always printed on the sheet surface 17 having a flat surface, as shown in FIG. 2. If the sheet surface is the surface of an egg carton, for example, the level of the reflected beam changes depending on the ruggedness 18 as the laser beams 12 scan the ruggedness 18 of the sheet surface 17. This change results in the noise in the output signal of the pin photodiode 16. This noise exhibits a greater level when the beams scan the white bar 14 than when they scan the black bar 15.
FIG. 3 shows the output waveform of each portion of the circuit shown in FIG. 1.
The output signal of the amplification unit 21 greatly changes at the edge portion of the boundary between the white bar 14 and the black bar 15. Therefore, the differentiation signal DF exhibits a large peak value +VDF at the edge portion of the white bar 14 and a large peak value xe2x88x92VDF at the edge portion of the black bar 15. The positive slice level signal +SL and the negative slice level xe2x88x92SL have a predetermined ratio to the positive peak value +V, and attenuate at a predetermined time constant with the passage of time.
When the level on the positive side of the differentiation signal DF becomes higher than the slice level +SL, the gate signal W-GATE is outputted. When the level on the negative side of the differentiation signal DF becomes higher than the negative slice level xe2x88x92SL, the gate signal B-GATE is outputted. The peak signal PKS is the signal the polarity of which changes for each peak contained in the differentiation signal DF. The logic AND of these gate signals W-GATE, B-GATE and the peak signal PKS gives the edge signal WEG representing the edge of the white bar 14 and the edge signal BEG representing the edge of the black bar 15. These edge signals WEG and BEG discriminate the white bar and the black bar.
When the noise due to the roughness 18 (see FIG. 2) of the sheet surface 17 is great, the level of the differentiation signal DF is raised above the slice level SLL by the noise portions 46 and 47 of the differentiation signal DF. Then, the gate signals W-GATE and B-GATE are outputted at portions other than the edge portions of the bars 14 and 15. In consequence, portions not having the edges 14 and 15 are judged erroneously as the edges.
A way to prevent such influences of the noises might be a method that increases the slice level SLL. However, a new problem arises when the slice level SLL is increased. When a bar code with a small black-and-white difference (or having low contrast), that is called xe2x80x9cLOW PCSxe2x80x9d, and a bar code having a small bar width in comparison with the beam, are scanned, for example, the amplitude of the electric signal of the output of the pin photodiode 16 becomes small. When such bar codes are read, the peak value VDF representing the edge of the bar of the differentiation signal DF becomes smaller at this time than the slice level SLL, in some cases, if the slice level is merely increased. Then, the problem develops in that the edge of the bar code cannot be detected even though the edge exists.
It is an object of the present invention to provide an optical code reader which, when a code is scanned with beams, can correctly binarize an electric signal and can reliably read the code even when noise is added to a reflected beam from the code, and even when the code has a small black-and-white difference, or even when the code has a small width.
The present invention is completed in order to accomplish the object described above.
In the optical code reader according to the present invention, a scanning mechanism scans the code to be read with beams, and reflected beams from the code are received by a beam receiving device, acquiring an electric signal. A differentiation unit differentiates the electric signal and outputs a differentiation signal. A slice level generation circuit is provided. This circuit generates a first slice level having a first ratio (slice ratio) which is constant with respect to the peak value of the differentiation signal and a second slice level having a second slice ratio which varies according to the peak value with respect to the peak value. The slice level generation circuit synthesizes the first and second slice ratios and outputs a synthetic slice level. A comparison unit compares the level of the differentiation signal with the synthetic slice level and outputs a binarized signal.
When the level of the differentiation signal becomes great in the present invention, the slice ratio of the slice level increases and approaches the peak value of the differentiation signal. Even if much noise is contained in the differentiation signal when the comparison circuit compares the level of the differentiation signal with the synthetic slice level, the level of the noise does not exceed the slice level because the slice level becomes high. Therefore, the judgement error of judging the noise as the edge of the code can be eliminated. When the level of the differentiation signal is small, the peak portion representing the edge of the differentiation signal can be made reliably greater than the slice level because the slice level is constant with respect to the peak value of the differentiation signal. Even when only a small differentiation signal can be obtained such as when a bar code has only a small black-and-white difference or when a bar code has a small bar width, the optical code reader according to the present invention can correctly binarize the code and can reliably read the code having a small black-and-white difference and the thin code even when the noise adds to the reflected beams from the code.